package com.junjun.ssm.Interceptor;



import com.junjun.ssm.entity.UserEntity;
import com.junjun.ssm.util.Verifier;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@Component
public class LoginInterceptor implements HandlerInterceptor {
    //进入应用控制器之前开始执行
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
      String token=request.getHeader("token");
      String result= Verifier.verifierJwt(token);
       if (StringUtils.hasLength(result)){

           return true;
           }
       return false;
    }
}
